<!-- 天建学校 -->
<template>
    <div class="page-box h100 display-flex czbj">
      <p class="title-label mb10">
        
        {{ titlesxr }}
    </p>
      <!-- sonRouter="yybureauFormationBJ" 为跳转新的页面编辑 -->
      <dxtable :dataJson="dataJson" :portUrl="portUrl" :formJson="formJson" :qx="qx" ref="databale" ></dxtable>
    </div>
  </template>
  <script lang='ts' setup>
  import dxtable from "../../components/util/dxtable.vue";
  import sort from "../../components/util/sort.vue";
  import { dxget, dxpost,qurl } from "../../util/index";
  import { NButton, NImage, NTag } from "naive-ui"
  import { h, ref, reactive } from "vue";
  const databale = ref();
  const cz = qurl()
  const initeer = () => {
    databale.value.initDataExpose();
  };
  let props = defineProps({
    titlesxr: { type: String,default:'校园新闻' },
    dxtype:{ type: String },
    dtype:{ type: String },
  })
  let dataJson = [
      {
          "title": "标题",
          "type": "input",
          "val": "",
          "icon": "dx-shurukuang",
          "span": 24,
          "key": "title",
          "width": "",
          "search": true,
          "istable": true,
          "required": false
      },
      {
          "title": "封面",
          "type": "img",
          "val": "",
          "icon": "dx-img",
          "span": 12,
          "key": "cover",
          "width": "",
          "search": false,
          "istable": true,
          "required": false,
          width:160,
      },
      {
          "title": "是否首页推荐",
          "type": "radio",
          "icon": "dx-radiobox",
          "val": "",
          width:100,
          render:(row)=>{
            return h(NTag, {
              type: row.ishome == 1? "success" : "warning",
            }, row.ishome == 1? "首页推荐" : "不推荐");
          }
      },
  {
    title: "添加时间",
    key: "addTime",
    width: 150,
  }];
  
  
  
  const qx = {
    DeletePermissionID: "tjxxnews1del", //删除
    EditPermissionIdentifier: "tjxxnews1bj", // 编辑
    NewPermissionIdentifier: "tjxxnews1xz", // 新建
    ViewPermissionID: "tjxxnews1ck", // 查看
  };
  const portUrl = "tjxx/textList/textList?zfl="+props.dxtype+'&dtype='+props.dtype
  
  let formJson = reactive([
      {
          "title": "标题",
          "type": "input",
          "val": "",
          "icon": "dx-shurukuang",
          "span": 24,
          "key": "title",
          "width": "",
          "search": false,
          "istable": true,
          "required": false
      },
      {
          "title": "封面",
          "type": "img",
          "val": "",
          "icon": "dx-img",
          "span": 12,
          "key": "cover",
          "width": "",
          "search": false,
          "istable": true,
          "required": false
      },
      {
          "title": "是否首页推荐",
          "type": "radio",
          "icon": "dx-radiobox",
          "val": "",
          "opt": [
              {
                  "label": "是",
                  "value": '1'
              },
              {
                  "label": "否",
                  "value": '2'
              }
          ],
          "span": 12,
          "key": "ishome",
          "width": "",
          "search": false,
          "istable": true,
          "required": false
      },
      {
          "title": "富文本",
          "type": "fwb",
          "val": "",
          "icon": "dx-m-fuwenben",
          "span": 24,
          "key": "text",
          "width": "",
          "search": false,
          "istable": true,
          "required": false,
          callBack:(data)=>{
            databale.value.setmodel('jianjie',data)
          }
      },
      {
          "val": props.dxtype,
          "key": "zfl",
      }, {
          "val": props.dtype,
          "key": "dtype",
      }
  ]);
  const czFun = {
    fun: (row) => {
      return [
        h(
          NButton,
          {
            type: "info",
            quaternary: true,
            onClick: async (e) => {
  
            },
          },
          "复制代码"
        )
  
      ];
    },
  };
  
  
  // 获取字典内容
  // const xtgxxmfl = async () => {
  //   const { data }: any = await dxget("dxgjAdmin/getzd", { name: 'xtgxxmfl' })
  //   dataJson[2].options = [
  //     {
  //       label: "全部",
  //       value: ""
  //     },
  //     ...data
  //   ]
  //   formJson[2].options = data
  //   xmlxSelect.value = data
  //   console.log(data);
  // }
  // xtgxxmfl()
  
  
  </script>
  <style scoped></style>
      